<extend name="Layout/application"/>

<block name="content">
    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-8">
                    <div class="page-header">
                        <h1>内容管理</h1>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">栏目编辑</div>
                        <div class="panel-body">
                            <!-- Nav tabs -->
                            <ul class="nav nav-tabs" role="tablist">
                                <li role="presentation" class="active"><a href="#home" role="tab"
                                                                          data-toggle="tab">栏目信息</a></li>
                                <li role="presentation"><a href="#profile" role="tab" data-toggle="tab">栏目内容</a></li>
                            </ul>
                            <form class="form-horizontal" role="form" method="post" action="{{:U('do_edit')}}">
                                <!-- Tab panes -->
                                <div class="tab-content">

                                    <div role="tabpanel" class="tab-pane active" id="home">
                                        <div class="form-group">
                                            <label for="inputEmail3" class="col-sm-2 control-label">父栏目</label>
                                            <input type="hidden" value="{{$edit_category.id}}" name="id">
                                            <input type="hidden" value="{{$edit_category.parent_id}}" id="id">
                                            <input type="hidden" value="{{$edit_category.content}}" id="contents">
                                            <input type="hidden" value="{{$edit_category.type}}" id="type">
                                            <input type="hidden" value="{{$edit_category.is_show}}" id="is_show">
                                            <div class="col-sm-10">
                                                <select class="form-control" id="inputEmail3" name="parent_id">
                                                  <option value="{{$edit_category.parent_id}}"><if condition="($edit_category.parent_id eq 0)">此栏目为顶级栏目</if></option>
                                                    <volist name="categories" id="c">
                                                        <option value="{{$c.id}}" <eq name="c.id" value="$edit_category.parent_id">selected</eq>><for start="1" end="$c['level']*2">&nbsp;&nbsp;</for>{{$c.name}}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="inputPassword3" class="col-sm-2 control-label">名称</label>
                                            <div class="col-sm-10">
                                                <input type="text" class="form-control" id="inputPassword3"
                                                       placeholder="栏目名称" name="name" value="{{$edit_category.name}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="inputPassword" class="col-sm-2 control-label">拼音</label>
                                            <div class="col-sm-10">
                                                <input type="text" class="form-control" id="inputPassword"
                                                       placeholder="拼音" name="pinyin" value="{{$edit_category.pinyin}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="inputPassword" class="col-sm-2 control-label">类型</label>
                                            <div class="col-sm-10">
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" class="radio1" name="type" id="blankRadio1"
                                                               value="1">
                                                        封面</label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" class="radio1" name="type" id="blankRadio2"
                                                               value="2">
                                                        列表</label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" class="radio1" name="type" id="blankRadio3"
                                                               value="3">
                                                        URL跳转</label>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="inputPassword" class="col-sm-2 control-label">是否跳转</label>
                                            <div class="col-sm-10">
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" class="radio2" name="is_show" id="blankRadio4"
                                                               value="1">
                                                        是</label>
                                                </div>
                                                <div class="radio">
                                                    <label>
                                                        <input type="radio" class="radio2" name="is_show" id="blankRadio5"
                                                               value="0">
                                                        否</label>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="inputPassword1" class="col-sm-2 control-label">URL</label>
                                            <div class="col-sm-10">
                                                <input type="text" class="form-control" id="inputPassword1"
                                                       placeholder="拼音" name="url" value="{{$edit_category.url}}">
                                            </div>
                                        </div>

                                    </div>
                                    <div role="tabpanel" class="tab-pane" id="profile">
                                        <textarea class="form-control" rows="" name="content"></textarea>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-offset-2 col-sm-10">
                                            <button type="submit" class="btn btn-primary">修改</button>
                                            <a href="{{:U('index')}}">
                                                <button type="button" class="btn btn-success">返回</button>
                                            </a>
                                        </div>
                                    </div>

                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="list-group">
                        <a href="{{:U('create')}}" class="list-group-item list-group-item-info sort_category">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 新增 (add)
                        </a>

                        <a href="javascript: void 0;" class="list-group-item list-group-item-info sort_category">
                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 排序 (sort)
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>

<block name="js">
    <script src="__PUBLIC__/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="__PUBLIC__/ckfinder/ckfinder.js"></script>
    <script>
        CKEDITOR.replace('content',
        {
        filebrowserBrowseUrl: '__PUBLIC__/ckfinder/ckfinder.html',
        filebrowserImageBrowseUrl: '__PUBLIC__/ckfinder/ckfinder.html?type=Images',
        filebrowserFlashBrowseUrl: '__PUBLIC__/ckfinder/ckfinder.html?type=Flash',
        filebrowserUploadUrl: '__PUBLIC__/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
        filebrowserImageUploadUrl: '__PUBLIC__/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
        filebrowserFlashUploadUrl: '__PUBLIC__/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
        });

        CKEDITOR.instances.content.setData($("#contents").val());

        $(function () {
            $(".option").each(function () {
                //alert($(this).val());
                if($(this).val()==$("#id").val()){
                    $(this).prop("selected",true);
                }
            });
            
            $(".radio1").each(function () {
                if($(this).val()==$("#type").val()){
                    $(this).prop("checked","checked");
                }
            });

            $(".radio2").each(function () {
                //alert($(this).val());
                if($(this).val()==$("#is_show").val()){
                    $(this).prop("checked","checked");
                }
            });

        })
    </script>
</block>